#include <iostream>
#include <cstdlib>
#include <string>

int main() {
    std::cout << "=== 构建时环境变量测试 ===" << std::endl;
    
    // 检查构建时是否加载了环境变量
    const char* project_name = std::getenv("PROJECT_NAME");
    const char* project_version = std::getenv("PROJECT_VERSION");
    const char* build_type = std::getenv("BUILD_TYPE");
    const char* compiler_flags = std::getenv("CUSTOM_COMPILER_FLAGS");
    const char* project_author = std::getenv("PROJECT_AUTHOR");
    const char* enable_tests = std::getenv("ENABLE_TESTS");
    
    bool all_loaded = true;
    
    std::cout << "项目名称: " << (project_name ? project_name : "未设置") << std::endl;
    if (!project_name || std::string(project_name) != "MyTestProject") {
        all_loaded = false;
    }
    
    std::cout << "项目版本: " << (project_version ? project_version : "未设置") << std::endl;
    if (!project_version || std::string(project_version) != "1.0.0") {
        all_loaded = false;
    }
    
    std::cout << "构建类型: " << (build_type ? build_type : "未设置") << std::endl;
    if (!build_type || std::string(build_type) != "Debug") {
        all_loaded = false;
    }
    
    std::cout << "编译器标志: " << (compiler_flags ? compiler_flags : "未设置") << std::endl;
    if (!compiler_flags || std::string(compiler_flags) != "-O2 -g") {
        all_loaded = false;
    }
    
    std::cout << "项目作者: " << (project_author ? project_author : "未设置") << std::endl;
    if (!project_author || std::string(project_author) != "Test Author") {
        all_loaded = false;
    }
    
    std::cout << "启用测试: " << (enable_tests ? enable_tests : "未设置") << std::endl;
    if (!enable_tests || std::string(enable_tests) != "true") {
        all_loaded = false;
    }
    
    std::cout << std::endl;
    
    if (all_loaded) {
        std::cout << "✅ 所有环境变量都已正确加载！" << std::endl;
        std::cout << "PROJECT_ENV_CONFIG功能测试通过！" << std::endl;
        return 0;
    } else {
        std::cout << "❌ 部分环境变量未加载，请检查配置" << std::endl;
        return 1;
    }
}